var layoutModule = {
    
       
    sameHeight: function(objects) {
       
        var maxHeight = 0;
       
        objects.each(function() {
           if($(this).height() > maxHeight)
               maxHeight = $(this).height();
        });
       
        objects.height(maxHeight);
        
        objects.animate({
            height: maxHeight
            },
            {
                duration : 300
            });
        
        
    },
    
    equalColumns: function() {
        
        var o1;
        var o2;
        
        $(".content").each(function() {
       
           
           o1 = $(this).find('.column:first');
           o2 = $(this).find('.column:last');



           if(o1.height() > o2.height()) {
               
                o2.animate({
                    height: o1.height()
                    },
                    {
                        duration : 100
                    });
               
           }
           else {
                o1.animate({
                    height: o2.height()
                    },
                    {
                        duration : 100
                    });
           }
              

        });

    },

    setWrapper: function() {
        
        return false;
        
        var fwidth = 0;
        var w = $(window).width();
        
        
        
        $('#menu li').each(function() {
            
            if((fwidth + $(this).outerWidth(true)) < w)
                fwidth += $(this).outerWidth(true);
        });
        
        fwidth += 10;

        if(fwidth < 750)
            return false;
        

        $("#wrapper").width(fwidth);
    },
 
    // Krymper menyn till halva storleken
    shrinkMenu: function() {
        
        $('#menu li').animate({
            opacity: 1,
            height: '30',
            paddingTop: '10'
            },
            {
                duration : 100
            });
        
    },
    
    
    show_form_transaction: function() {
       
        $.ajax({
            type: "GET",
            url: "resources/snippets/add_transaction.xhtml",
            dataType: "html",
            success: function(html) {
                
                var d = new Date();
                var dt = d.getFullYear()+"-"+d.getMonth()+"-"+d.getDate()+
                    "T"+d.getHours()+":"+d.getMinutes()+":00";
               $(html).find('input[name=date]').val(dt);
               
               layoutModule.showPopup(html);
         }}); 
    },
    
    showFormError: function(res) {
        
        $('form').prepend(res);
        
    },
    
    hidePopup: function() {
        
        $('.popup').fadeOut(200, function() {
           $('.popup').remove();
           $('#hide_area').fadeOut(500, function() {
               $(this).remove();
           });
           
       });    
    
    },
    
    loadContent: function(where, content) {
        
    $(where).fadeOut(200, function() {
            
            $(this).html(content).fadeIn(200, function() {
                window.setTimeout(layoutModule.equalColumns, 100);
                
            });
            
        });

    },
    
    toneRedirect: function(url) {
        
        $('html').fadeOut(500, function() {
             window.location.replace(url);
        });
        
        
    },
    
    
    showPopup: function(pop) {
        
        
       $("#popup_area").hide();
       $("#popup_area").html(pop);
       $("#popup_area").before('<div id="hide_area"></div>');
       $("#popup_area").fadeIn(300);
       $("#popup_area input:first").focus();

        
        
       //hidePopup();
       
     
    }
    
}